//@zedd 
$(document).ready(function(){
//topbar search
$("#search_index").click(function(){
	$("#searchBox").slideToggle(300);
});
//dot slider
	dot_number = 0;
	$(".infoScroll").swipe({
		swipeLeft:function(){
		if(dot_number<$(".info").length-1){
			dot_number++;
			$(this).find(".info_s").animate({left: "-"+dot_number*320+"px" }, 500);
		    $(this).find(".info_d span").css({"background":"#e23d31"});
			$(this).find(".info_d").find("span:nth-child("+(dot_number+1)+")").css({"background":"#bbb"});
			if(dot_number==4){
				viceCardBusiness();
			}
		}	
		else{
			dot_number=0;
			$(this).find(".info_s").animate({left: "-"+dot_number*320+"px" }, 500);
		    $(this).find(".info_d span").css({"background":"#e23d31"});
			$(this).find(".info_d").find("span:nth-child("+(dot_number+1)+")").css({"background":"#bbb"});
		}
	},
	swipeRight:function(){
		if(dot_number>0){
			dot_number--;
			$(this).find(".info_s").animate({left: "-"+dot_number*320+"px" }, 500);
			$(this).find(".info_d span").css({"background":"#e23d31"});
			$(this).find(".info_d").find("span:nth-child("+(dot_number+1)+")").css({"background":"#bbb"});
		}
	}
	});

});
/**
 * 了解增值业务获取积分
 */
function viceCardBusiness(){
	$.ajax({
		url : "/ajax/activity/userKnowledge.action",
		type : "post",
		async : false,
		dataType : "json",
		success : function(root) {
			var jsonObj = eval('(' + root + ')');
				if(jsonObj.mail=="请先登录"){
				}else {
					if(jsonObj.resoult){
						var intgerStr = jsonObj.mail;
						var itgerStrs = intgerStr.split("_");
						$("#span_activity").text("您已获得"+itgerStrs[1]+"点达人积分");
						alert(itgerStrs[0]);
					}else {
						alert(jsonObj.mail);
					}
				}
				
		}
	});
}
/**
 * 订购炫铃获取积分
 */
function userOrder(){
	$.ajax({
		url : "/ajax/activity/queryUserOrderNum.action",
		type : "post",
		async : false,
		dataType : "json",
		success : function(root) {
			var jsonObj = eval('(' + root + ')');
				if(jsonObj.mail=="请先登录"){
					alert(jsonObj.mail);
					location.href = "/login/login.3.jsp?url3=flowms";	
				}else {
					alert(jsonObj.mail);
				}
				
		}
	});
}


function exchangeIntegral(integralId){
	var id = integralId.substring(integralId.indexOf("_")+1);
	$.ajax({
		url : "/ajax/activity/exchangeIntegral.action",
		type : "post",
		async : false,
		data :"integralId="+id,
		dataType : "json",
		success : function(root) {
			   var jsonObj = eval('(' + root + ')');
				if(jsonObj.mail=="请先登录"){
					alert(jsonObj.mail);
					location.href = "/login/login.3.jsp?url3=flowms";	
				}else {
					alert(jsonObj.mail);
				}
				
		}
	});
}